﻿namespace FluentMvc.Test.Controllers
{
    using System.Web.Mvc;
    using Models;

    public class HomeController : Controller
    {
        public ViewResult Index()
        {
            return View(new User());
        }

        [HttpPost]
        public ActionResult Register(User user)
        {
            return View("Index", user);
        }

        public JsonResult UsernameExists(string username)
        {
            if (username == "hosein")
                return new JsonResult {Data = true, JsonRequestBehavior = JsonRequestBehavior.AllowGet};
            return new JsonResult {Data = "username is not valid", JsonRequestBehavior = JsonRequestBehavior.AllowGet};
        }
    }
}